package com.peas.platform.module.icims.contract.initial.api;

import com.peas.platform.common.core.dto.ResponseDto;
import com.peas.platform.module.icims.contract.initial.api.resp.*;
import com.peas.platform.module.icims.contract.initial.service.ContractInitialCashService;
import com.peas.platform.module.icims.contract.initial.service.ContractInitialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

@Api(tags = "自定义接口-[合同管理]控制台")
@RestController
@RequestMapping("/api/v1/customContractConsole")
public class CustomContractConsoleController {

    @Resource
    private ContractInitialService contractInitialService;
    @Resource
    private ContractInitialCashService contractInitialCashService;

    @ApiOperation(value = "合同台账")
    @GetMapping(value = "/getContractLedger")
    public ResponseDto<ContractLedgerResp> getContractLedger() {
        ContractLedgerResp r = contractInitialService.getContractLedger();
        return ResponseDto.getSuccessResponseDto(r);
    }

    @ApiOperation(value = "合同状态")
    @GetMapping(value = "/getContractStatus")
    public ResponseDto<ContractStatusResp> getContractStatus() {
        ContractStatusResp r = contractInitialService.getContractStatus();
        return ResponseDto.getSuccessResponseDto(r);
    }

    @ApiOperation(value = "签约前10企业排名")
    @GetMapping(value = "/getContractTop10")
    public ResponseDto<List<ContractTop10Resp>> getContractTop10() {
        List<ContractTop10Resp> r = contractInitialService.getContractTop10();
        return ResponseDto.getSuccessResponseDto(r);
    }

    @ApiOperation(value = "应收情况")
    @GetMapping(value = "/getContractReceivable")
    public ResponseDto<ContractReceivableResp> getContractReceivable() {
        ContractReceivableResp r = contractInitialCashService.getContractReceivable();
        return ResponseDto.getSuccessResponseDto(r);
    }

    @ApiOperation(value = "应付情况")
    @GetMapping(value = "/getContractPayable")
    public ResponseDto<ContractPayableResp> getContractPayable() {
        ContractPayableResp r = contractInitialCashService.getContractPayable();
        return ResponseDto.getSuccessResponseDto(r);
    }

    @ApiOperation(value = "预警提醒")
    @GetMapping(value = "/getContractWarning")
    public ResponseDto<ContractWarningResp> getContractWarning() {
        ContractWarningResp r = new ContractWarningResp();
        r.setValue1(1);
        r.setValue2(BigDecimal.valueOf(22));
        r.setValue3(333);
        r.setValue4(BigDecimal.valueOf(4444));
        r.setValue5(55555);
        r.setValue6(BigDecimal.valueOf(666666));
        return ResponseDto.getSuccessResponseDto(r);
    }

    @ApiOperation(value = "合同收付金额")
    @GetMapping(value = "/getContractReceiptPayment")
    public ResponseDto<ContractReceiptPaymentResp> getContractReceiptPayment(@ApiParam(name = "year", value = "年度") Integer year,
                                                                             @ApiParam(name = "type", value = "收付类型(1收款、2付款)") String type) {
        ContractReceiptPaymentResp r = contractInitialCashService.getContractReceiptPayment(year, type);
        return ResponseDto.getSuccessResponseDto(r);
    }

}
